﻿<ul class="unit-grid payment card">
@if((Model.Items as IEnumerable<dynamic>).Any())
{
    foreach(var i in Model.Items)
    {
        string status = String.Empty;
        if(JDM.HasFlags(i.Flags, "Voided"))
        {
            status = "Voided";
        }
        else if(JDM.HasFlags(i.Flags, "Refunded"))
        {
            status = "Refunded";
        }
        else if(JDM.HasFlags(i.Flags, "Pending"))
        {
            status = "Pending";
        }
        else if(JDM.HasFlags(i.Flags, "Authorized"))
        {
            status = "Authorized";
        }
        else if(JDM.HasFlags(i.Flags, "Captured"))
        {
            status = "Captured";
        }
        <li class="unit payment card @(!JDM.HasFlags(i.Flags, "Active") ? "inactive" : String.Empty)">
            <header>
                @T(Res.Name("Payment"), 
                    JDM.Int32(i.EntityID), 
                    Svc.Date((DateTime)JDM.DateTime(i.CreatedOn)), 
                    T(Res.In("API").Of("Enum").Of("PaymentFlags").Name(status)))
            </header>
            <section>
                <table class="key-value highlight-key">
                    <tr>
                        <td>@T(Res.In("Common").Of("Vocab").Name("Guid"))</td>
                        <td>@JDM.String(i.Guid)</td>
                    </tr>
                    <tr>
                        <td>@T(Res.Name("Invoice"))</td>
                        <td>@JDM.Guid(i.Invoice.Guid)</td>
                    </tr>
                    <tr>
                        <td>@T(Res.Name("HandlingFee"))</td>
                        <td>@Svc.Price((decimal)JDM.Decimal(i.HandlingFee))</td>
                    </tr>
                    <tr>
                        <td>@T(Res.Name("Amount"))</td>
                        <td>@Svc.Price((decimal)JDM.Decimal(i.Amount))</td>
                    </tr>
                </table>
            </section>
            <footer>
                <ul class="inlinebar">
                    <li><a href="@Url.Action(Loc.Act("Show").Set(new
                    {
                        id = JDM.Int32(i.EntityID)
                    }).Localized())">@T(Res.In("Common").Of("Act").Name("Show"))</a></li>
                </ul>
            </footer>
        </li>
    }
}
else
{
    <li class="empty"><span>@T(Res.In("Common").Of("Expr").Name("NoData"))</span></li>
}
</ul>

